<!--
 * @Author: your name
 * @Date: 2021-07-20 14:21:01
 * @LastEditTime: 2021-10-25 18:28:26
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \usp-osm-frondend\src\views\orderCenter\suborder\invoiceDetails.vue
-->
<template>
  <div
    class="white-content"
    v-loading="pageLoading"
    element-loading-text="loading"
  >
    <div class="newPageTitle">
      <span class="backIcon" @click="goBack"><i class="el-icon-back"></i></span>
      <h1 style="display: inline-block; margin-left: 10px; font-weight: bold">
        查看发票详情
      </h1>
    </div>
    <div class="detail-content-section">
      <h2>开票信息</h2>
      <el-form label-width="140px" label-position="right">
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="开票状态：">
              {{ getDictionaryNameByCode('BILLINGSTATES', datas.states)  }}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="开票电子邮箱：">
              {{ datas.email }}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="开票手机号：">
              {{ datas.buyerPhone }}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="购方名称：">
              {{ datas.buyerName }}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="购方纳税人识别号：">
              {{ datas.buyerTaxpayerNumber  }}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="购方地址：">
              {{ datas.buyerAddress }}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="购方电话：">
              {{ datas.buyerPhone }}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="购方银行卡账号：">
              {{ datas.buyerBankNo }}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="购方开户行：">
              {{ datas.buyerBankName}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="收货人名称：">
              {{ datas.contactName }}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="收货人手机号：">
              {{ datas.contactPhone}}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="收货人地址：">
              {{ datas.contactAddress}}
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <div class="detail-content-section">
      <h2>发票信息</h2>
      <el-form label-width="140px" label-position="right">
        <el-row :gutter="40">
          <el-col :span="8">
            <el-form-item label="发票代码：">
              {{ datas.invoiceCode }}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="发票号码：">
              {{ datas.invoiceNo }}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="发票类型：">
              {{ getDictionaryNameByCode('INVOICETYPE', datas.invoiceType)  }}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="40">
          <el-col :span="8">
            <el-form-item label="含税总金额：">
              {{ datas.includingTaxTotalAmount }}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="总税额：">
              {{ datas.tax }}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="不含税总金额：">
              {{ datas.excludingTaxTotalAmount }}
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <div class="detail-content-section">
      <h2>时间信息</h2>
      <el-form label-width="140px" label-position="right">
        <el-row :gutter="40">
          <el-col :span="8">
            <el-form-item label="开票时间：">
              {{ datas.billingTime }}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="创建时间：">
              {{ datas.createTime | timestampToChange('time') }}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="更新时间：">
              {{ datas.updateTime | timestampToChange('time') }}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="作废时间：">
              {{ datas.cancelTime }}
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <div>
      发票上传地址：<span class="colorLink">{{datas.uploadUrl}}</span>
    </div>
  </div>
</template>

<script>
import { setRouterParams, getRouterParams } from '@/utils/auth'
import { common } from '@/mixins/common'
import { mapGetters } from 'vuex'
import { getInvoiceDetail } from '@/api/order/'
export default {
  name: 'invoiceDetails',
  data () {
    return {
      datas: {
      },
      pageLoading: false,
      id: ''
    }
  },
  mixins: [common],
  computed: {
    ...mapGetters(['lookupItems'])
  },
  mounted () {
    let params = {}
    if (this.$route.params.id) {
      setRouterParams(this.$route)
      params = this.$route.params
    } else {
      params = getRouterParams(this.$route)
    }
    this.id = params.id
    this.getDetail(this.id)
  },
  methods: {
    goBack () {
      this.$router.go(-1)
    },
    getDetail (id) {
      getInvoiceDetail(id).then(res => {
        if (res) {
          if (Number(res.code) === 1) {
            this.datas = res.obj
          } else {
            this.$alert('获取发票信息失败')
          }
        }
      })
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
.footer {
  width: 100%;
  margin: 0;
}
.detail-section {
  h2 {
    margin: 15px 0;
    font-weight: bold;
  }
}
/deep/ .el-form-item {
  margin-bottom: 0;
}
</style>
